package com.zmn.plat.dubbo.impl.orderconfig.track.reason;

import java.util.List;

import javax.annotation.Resource;

import org.apache.dubbo.config.annotation.Service;

import com.zmn.common.constant.GlobalConsts;
import com.zmn.common.dto2.ResponseDTO;
import com.zmn.plat.business.interfaces.orderconfig.track.reason.OrderTrackReasonBService;
import com.zmn.plat.common.dto.orderconfig.track.OrderTrackReasonDRO;
import com.zmn.plat.common.exception.PlatException;
import com.zmn.plat.dubbo.interfaces.orderconfig.track.reason.OrderTrackReasonListRemoteService;
import com.zmn.plat.dubbo.utils.DubboConsts;

import lombok.extern.slf4j.Slf4j;

/**
 * @author tanbiao
 * @description
 * @modifier
 * @since 2020/12/3 14:09
 **/
@Service(version = DubboConsts.INTERFACE_VERSION, validation = "true")
@Slf4j
public class OrderTrackReasonListRemoteServiceImpl implements OrderTrackReasonListRemoteService {
    @Resource
    private OrderTrackReasonBService orderTrackReasonBService;

    @Override
    public ResponseDTO<List<OrderTrackReasonDRO>> listByTrackId(Integer trackId) {
        log.info("listByTrackId trackId:{}", trackId);
        try {
            List<OrderTrackReasonDRO> droList = orderTrackReasonBService.listByTrackId(trackId);
            return ResponseDTO.success(droList);
        } catch (PlatException e) {
            return ResponseDTO.fromErrorCodeTable(e.getErrorCode());
        } catch (Exception e) {
            log.error("listByCategIdAndBizType trackId:{}", trackId, e);
            return ResponseDTO.fail(GlobalConsts.FAILD_MSG);
        }
    }

    @Override
    public ResponseDTO<List<OrderTrackReasonDRO>> listByTrackIds(List<Integer> trackIds) {
        log.info("listByTrackIdList trackId:{}", trackIds);
        try {
            List<OrderTrackReasonDRO> droList = orderTrackReasonBService.listByTrackIds(trackIds);
            return ResponseDTO.success(droList);
        } catch (PlatException e) {
            return ResponseDTO.fromErrorCodeTable(e.getErrorCode());
        } catch (Exception e) {
            log.error("listByTrackIdList trackId:{}", trackIds, e);
            return ResponseDTO.fail(GlobalConsts.FAILD_MSG);
        }
    }
}
